Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

prometheus: Add settings to prometheus plugin #87

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

yolossn
Copy link
Contributor

@yolossn yolossn commented Oct 3, 2024

This patch adds settings to the prometheus plugin
allowing the users to configure the service
address, timespan, enable metrics for each
cluster.

Fixes:
#24

Includes the fix suggested here:
#37 (comment)

Steps to Test:

  1. Run prometheus plugin from the prom_settings branch.
  2. Go to settings and configure the prometheus plugin, ie choose auto detect or provide service details to reach the prometheus service in the cluster.
  3. Check if the configuration is working for the cluster by going to pod/namespace detail view.

This patch adds settings to the prometheus plugin
allowing the users to configure the service
address, timespan, enable metrics for each
cluster.

Signed-off-by: yolossn <[email protected]>
@illume
Copy link
Contributor

illume commented Oct 8, 2024

Is there an issue to link this to? Can you please add a "how to test" section to the PR description?

Copy link
Contributor

@illume illume left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few notes about documenting/testing/type names. I guess most are nits/consistency things. Probably some things could be broken out into separate commits.

I need to know how this can be tested and the related issue(s) before I can test further.

@@ -12,6 +55,7 @@ export interface ChartProps {
dataProcessor: (data: any) => any[];
}>;
fetchMetrics: (query: object) => Promise<any>;
interval: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please document these fields?

* @param {Function} props.onDataChange - The function to call when the data changes.
* @returns {JSX.Element} The Settings component.
*/
export function Settings(props) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a SettingsProps interface with the docs in there?

@@ -0,0 +1,170 @@
import { NameValueTable } from '@kinvolk/headlamp-plugin/lib/components/common';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Component filenames should usually be capital named the same as the component Settings.tsx. Putting them in a folder (Settings/Settings.stories.tsx, Settings/Settings.tsx etc) makes it a bit easier as the number of components grows or there begins to be a lot of files for that component.

* @param {string} interval - The time interval (e.g., '10m', '1h', '24h', 'week').
* @returns {Object} An object containing the 'from' timestamp, 'to' timestamp, and 'step' in seconds.
*/
export function getTimeRange(interval: string): { from: number; to: number; step: number } {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there somewhere this is specified? A URL to some docs or code perhaps?

* @returns {Object} An object containing the 'from' timestamp, 'to' timestamp, and 'step' in seconds.
*/
export function getTimeRange(interval: string): { from: number; to: number; step: number } {
const now = Math.floor(Date.now() / 1000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function could use some tests.

export function CPUChart(props: { query: string; prometheusPrefix: string; autoRefresh: boolean }) {
const xTickFormatter = createTickTimestampFormatter();
export function CPUChart(props: {
query: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please document these fields? CPUChart could be in a CPUChart.tsx, because in general one file one component is better.

Can you please create a CPUChartProps interface for these fields?

@@ -1,7 +1,7 @@
{
"name": "prometheus",
"name": "@headlamp-k8s/prometheus",
Copy link
Contributor

@illume illume Oct 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will affect how this is installed.

How to handle this? At minimum a note in the release notes (or in the README?) should warn people to remove their old prometheus plugin, what the old one is called and what the new folder name is called.

This could also affect settings/permissions for running plugins.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the app/ bundling will need to be changed to get the new plugin name too?

@illume
Copy link
Contributor

illume commented Oct 8, 2024

With these changes will it work with Azure Monitor? I started an issue for this here:

I think these are the related issues for this PR?

@illume
Copy link
Contributor

illume commented Oct 8, 2024

This comment was made in this issue: #24 (comment)

In addition, the message is not very clear: "Install Prometheus for accessing metrics charts" Does this mean installing a Prometheus server or the Prometheus plugin for Headlamp?

Before closing #24 that should addressed IMHO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants